/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-09-11
 * Time: 17:28
 */

/*class MyArray {
    public Object[] array = new Object[10];

    public void setvalue( int pos,Object value) {
        array[pos] = value;
    }

    public Object getvalue(int pos) {
        return array[pos];
    }
}*/

    //<>代表当前类是泛型类 它只是一个占位符
class MyArray<T> {
    public Object[] array = new Object[10];

    public void setvalue( int pos,T value) {
        array[pos] = value;
    }

    public T getvalue(int pos) {
        return (T)array[pos];
    }
}

public class Test {
    //就是将类型进行了传递；

    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<Integer>();

        myArray.setvalue(0,100);
        myArray.setvalue(2,100);
        int a=  myArray.getvalue(2);

        System.out.println("=========================");

        MyArray<String> myArray2 = new MyArray<String>();

        myArray2.setvalue(0,"weer");
        myArray2.setvalue(2,"eee");

        String ret = myArray2.getvalue(2);
    }
}
